let names = localStorage.getItem('已登录')
if (names) {
    let html = ''
    html = `
        <div type="button" style="color:#E7E7E7 ;position: relative;" id="reg">
            <img src="https://img.youpin.mi-img.com/shopcenter/7dhur6i77hg_11350267611625208274363.png" width=30
                alt="">
            <div>我&nbsp;<svg fill="#ccc" xmlns="http://www.w3.org/2000/svg" style="width: 12px;height:7px"
                    viewBox="0 0 40 22.5">
                    <path
                        d="M39.28.72h0a2.49,2.49,0,0,0-3.5,0L20,16.53,4.23.72A2.48,2.48,0,0,0,.72,4.23L18.24,21.78A2.48,2.48,0,0,0,20,22.5a2.52,2.52,0,0,0,1.77-.72L39.28,4.23A2.5,2.5,0,0,0,39.28.72Z">
                    </path>
                </svg>
            </div>
            <ul class="isul">
                <li class="isli">我的订单</li>
                <li>退款/售后</li>
                <li>我的资产</li>
                <li>我的收藏</li>
                <li>地址管理</li>
                <li>退出登录</li>
            </ul>
        </div>`
    document.querySelector("#mycontent").innerHTML = html
    let isul = document.querySelector('.isul')
    let mycontent = document.querySelector('.mycontent')
    mycontent.onmouseover = function () {
        isul.style.display = 'block'
    }
    isul.onmouseout = function (e) {
        isul.style.display = 'none'

    }
    let liObj = isul.children
    Array.from(liObj).forEach((v) => {
        if (v.innerHTML == '退出登录') {
            v.onclick = function () {
                console.log(1);
                localStorage.removeItem('已登录')
                location.reload()
            }
        }if (v.innerHTML == '我的订单') {
            v.onclick = function () {
                location.href='http://127.0.0.1:5500/xiaomiyoupin/user.html'
            }
        }if (v.innerHTML == '我的收藏') {
            v.onclick = function () {
                location.href='http://127.0.0.1:5500/xiaomiyoupin/collect.html'
                
            }
        }if (v.innerHTML == '我的资产') {
            v.onclick = function () {
               location.href='http://127.0.0.1:5500/xiaomiyoupin/asset.html'
            }
        }if (v.innerHTML == '地址管理') {
            v.onclick = function () {
               location.href='http://127.0.0.1:5500/xiaomiyoupin/address.html'
            }
        }
    })
} else {
    let btnCl = document.getElementById('reg')
    btnCl.onclick = function btnClFn() {
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            shadeClose: true,
            skin: '',
            btn: ['同意并继续', '不同意'],
            content: `<div class="undefined layout-horizontal-vertical"><span class="close layui-layer-close"><div style="width: 13px; height: 13px; cursor: default;"><svg fill="#ccc" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><path d="M32.5.68,18,15.17,3.5.68A2,2,0,0,0,.68,3.5L15.17,18,.68,32.5A2,2,0,0,0,3.5,35.32L18,20.83,32.5,35.32a2,2,0,0,0,2.82-2.82L20.83,18,35.32,3.5A2,2,0,0,0,32.5.68Z"></path></svg></div></span><div class="agreement-container"><p class="title">声明与政策</p><div class="content"><p>欢迎您来到小米有品！</p><p>我们依据最新法律法规要求，制定并更新了<a target="_blank" href="https://daren.xiaomiyoupin.com/ewen/pageFromId?id=cxsew05x0x0ch53v" rel="noopener noreferrer">《隐私政策》</a><span class="color-gold">、</span><a target="_blank" href="https://m.xiaomiyoupin.com/mr/60013c77c9e77c0001f35060" rel="noopener noreferrer">《小米有品用户协议》</a>以及<a target="_blank" href="https://m.xiaomiyoupin.com/mr/60014809cff47e0001f66ad6" rel="noopener noreferrer">《小米帐号使用协议》</a>。</p><p>您需阅读并同意相关政策条款方可进行登录。</p></div></div>`
        });
        document.querySelector('.layui-layer-btn0').href='http://127.0.0.1:5500/xiaomiyoupin/login.html'
    }
}
let cart = document.querySelector('.cart-icon')
cart.onclick = function () {
    window.location.href = 'http://127.0.0.1:5500/xiaomiyoupin/cart.html'
}
document.querySelector('#license').onclick = function () {
    window.location.href = "https://daren.xiaomiyoupin.com/ewen/pageFromId?id=gurkg3d4bh7bbe6q"
}
document.querySelector('#protocol').onclick = function () {
    window.location.href = "https://daren.xiaomiyoupin.com/ewen/pageFromId?id=ytf4mzipem9cr7fj"
}
let logo = document.querySelector('.logo')
let addgood = document.querySelector('.btn-brank-one')
let buyGood = document.querySelector('.btn-brank-two')
let btnBox = document.querySelectorAll('.btn-box')
// let spanShow = document.querySelector('.span-icon')
// spanShow.onmouseover = function () {
//     spanShow.nextElementSibling.style.display = 'block'
// }
// spanShow.nextElementSibling.onmouseleave = function () {
//     spanShow.nextElementSibling.style.display = "none"
// }
logo.onclick = function () {
    window.location.href = 'http://127.0.0.1:5500/xiaomiyoupin/index.html'
}
